asp ||~||2||~||5||~||12||~||23||~|| 我想如果当数据像||~||12然后切取后面的所有字符,求写法

来源:百度知道 编辑:UC知道 时间:2024/07/07 09:46:29
asp ||~||2||~||5||~||12||~||23||~|| 我想如果当数据像||~||12然后切取后面的所有字符,结果读出来的就是||~||2||~||5||~||12,如果当数据像||~||5,结果读出来的就是||~||2||~||5,求写法。

likeit=||~||5
test=||~||2||~||5||~||12||~||23||~||
for i=1 to len(test)
if mid(test,i,len(likeit))=likeit then
need=left(test,i+len(likeit)-1)
exit for
end if
next

<%
str="||~||2||~||5||~||12||~||23||~||"
response.write newstr(str,5)

function newstr(s1,s2)
ss="||~||"&s2&"||~||"
if instr(s1,ss)=0 then exit function
newstr=left(s1,instr(s1,ss)+4+len(s2))
end function
%>

str="||~||2||~||5||~||12||~||23||~||"
inputstr="||~||2" //这个是你自己输入的
response.write right(str,len(str)-len(inputstr))